Application server systems provide an environment that allows client applications to implement services over a server network. The application server network may include vendor resources for providing services to the client applications. One such application server system is Web Logic Server, provided by BEA Systems of San Jose, Calif.
As vendor resources and application server utilities are used by client applications, it is often necessary to introduce adapters or proxies to mediate requests between clients and application server resources. A proxy is a class that has the same interface as some other class that it is taking the place of. An adapter takes the place of some class and exposes it through a different interface. A typical application server system implements a large number of proxies as resources are invoked and other services are performed. Many of these proxies require substantial amounts of code while often utilized for limited periods of time. Thus, it is not desirable to implement the interfaces for the lifetime of the application server system.
One approach is to have a user initiate code generation for the interfaces only when the interface is actually needed. In this case, a client application may run a code generation tool to statically generate a JAVA™ file and compile the JAVA™ file into a class file. The user then makes the class available to the JAVA™ virtual machine. This approach is undesirable because it requires a user to manually perform many steps to generate the code.
Another method for generating interfaces involves JAVA™ dynamic proxies. JAVA™ dynamic proxies require that an interface and an invocation handler be provided by a user. In return, the JAVA™ dynamic proxy generation system provides a class that will forward invocations to the invocation handler. JAVA™ dynamic proxies are limited in the types of classes that they generate. It is not possible, for example, to generate a class that is a subclass of a user defined class. Another problem with dynamic proxies is that they are not as efficient as dynamic code generation. To implement many types of proxies, it is often necessary to use reflection within the invocation handler. Reflection is not as efficient as early bound invocation. There is also a cost associated with the way that dynamic proxies marshal the arguments for an invocation into an object array.
What is needed is an improved system and method for generating program code at runtime for any type of class.